package com.sanmina.code;

import java.io.File;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.Charset;

public class CodeDemo {
	public static void main(String[] args) {
		String s = "中文编码格式！";
		String charSet = "UFT-8";
		try {
			byte b[] = s.getBytes("GBK");
			for (byte c : b) {
				System.out.print(c);
			}
			String n = new String(b, "GBK");
			System.out.println("\n" + n);
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		Charset charset = Charset.forName("UTF-8");
		ByteBuffer buffer = charset.encode(s);
		CharBuffer charBuffer = charset.decode(buffer);
		System.out.println(charBuffer);
		
		
		File f = new File("/home/mercy_yang/Downloads/"
				+ "spring+extjs4视频+jar/spring-annotation/"
				+ "37. 尚硅谷_佟刚_Spring_代码及PPT");
		String[] list = f.list();
		for (String fs : list) {
			System.out.println("####"+fs);
		}
		try {
			byte[] s2 = list[1].getBytes("UTF-8");
			System.out.println(s2);
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
//		ByteBuffer buffer2 = charset.encode(s2);
//		charBuffer = charset.decode(buffer2);
		
	}

}
